package com.luzhikun.kickUser;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author Rookie Coder
 * @Description
 * @Date
 **/
public class MyServeltContextLister implements ServletContextListener {
    /*
     * @Author liu-miss
     * @Description 监听应用启动的时候------------记得注册监听器
     * @Date 18:24 2021/5/3
     * @Param [sce]
     * @return void
     **/
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        //  创建一个Map，key为用户名，value为与当前用户绑定的session对象
        Map<String, HttpSession> map = new HashMap<>();
        // 获取到全局域
        ServletContext sc = sce.getServletContext();
        // 将这个map放入全局域中
        sc.setAttribute("map", map);


    }
}
